<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- 引入ElementUI样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <!-- 引入ElementUI组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">


    <el-table ref="multipleTable" :data="tableData" size="small" current-row-key="id"  stripe highlight-current-row
              @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="100"></el-table-column>
        <el-table-column prop="fileName" label="档案号" align="center"></el-table-column>
        <el-table-column prop="name" label="姓名" align="center"></el-table-column>
        <el-table-column prop="sex" label="性别" align="center"></el-table-column>
        <el-table-column prop="age" label="年龄" align="center"></el-table-column>
        <el-table-column prop="healthManage" label="健康管理师" align="center"></el-table-column>
        <el-table-column prop="regTime" label="注册时间" align="center"></el-table-column>
        <el-table-column prop="phoneNumber" label="手机号" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
            <template slot-scope="scope">
                <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
                <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
            </template>
        </el-table-column>
    </el-table>
    <div style="margin-top: 20px">
        <el-button @click="toggleSelection()">取消选择</el-button>
    </div>
    <div class="pagination-container">
        <el-pagination
                align="center"
                class="pagination"
                @current-change="handleCurrentChange"
                :current-page="pagination.currentPage"
                :page-size="pagination.pageSize"
                layout="total, prev, pager, next, jumper"
                :total="pagination.total">
        </el-pagination>
    </div>


</div>
<script>
    new Vue({
        el: '#app',
        data: {
            //定义VUE对象的模型数据，用于table展示
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize:2,//每页显示的记录数
                total:0,//总记录数
                queryString:null//查询条件
            },
            tableData: [
                {regTime: '2019.10.10', name: '小明', fileName: '北京'},//每个json对象对应表格中一条数据
                {regTime: '2019.10.10', name: '小明', fileName: '北京'},
                {regTime: '2019.10.10', name: '小明', fileName: '北京'},
                {regTime: '2019.10.10', name: '小明', fileName: '北京'},
                {regTime: '2019.10.10', name: '小明', fileName: '北京'},
                {regTime: '2019.10.10', name: '小李', fileName: '南京'}
            ],
            multipleSelection: [],
        },
        methods: {
            toggleSelection(rows) {
                if (rows) {
                    rows.forEach(row => {
                        this.$refs.multipleTable.toggleRowSelection(row);
                    });
                } else {
                    this.$refs.multipleTable.clearSelection();
                }
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            handleUpdate(row) {
                alert(row.name);
            },
            handleDelete(row) {
                alert(row.date);
            }
        }


    });
</script>
</body>
</html>
